﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Manage.Master" AutoEventWireup="true"
    CodeBehind="RecordManage.aspx.cs" Inherits="RainyPWS.Web.Admin.RecordManage" %>
<%@ MasterType TypeName="RainyPWS.Web.Admin.Manage" %>
<%@ Import Namespace="RainyPWS.Common" %>
<%@ Register Src="controls/TypeControl.ascx" TagName="TypeControl" TagPrefix="uc1" %>
<%@ Register Src="controls/Pager.ascx" TagName="Pager" TagPrefix="uc2" %>
<%@ Register assembly="RainyPWS.Controls" namespace="RainyPWS.Controls" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="js/Dialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        var refreshBtn = "<%=btnRefresh.ClientID %>";
        function UpdateRecordType(id, status){
            var url = '<%=Page.ResolveUrl("~/CommonHandler/RecordHandler.ashx") %>';
            var data = {
                act: "updaterecordtype",
                id: id,
                status: status
            };
            $.post(url, data, RecordCallBack);
        }
        function RecordCallBack(data) {
            if (data == "yes") {
                $("#" + refreshBtn).click();
            } else {
                alert("状态修改失败");
            }
        }
        function ConfirmCmd(type) {
            if (type == 1) {
                return ConfirmMsg("确认发布吗？");
            } else if (type == 2) {
                return ConfirmMsg("确认取消发布吗？");
            } else if (type == 3) {
                return ConfirmMsg("确认删除吗？");
            } else if (type == 4) {
                return ConfirmMsg("确认取消删除吗？");
            }
        }
        function ConfirmMsg(msg) {
            return window.confirm(msg);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table cellpadding="0" cellspacing="0" border="0" class="mianTable">
        <tr>
            <td class="tableLeft">
                <uc1:TypeControl ID="TypeControl2" runat="server" />
            </td>
            <td class="tableRight">
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                    <Scripts>
                        <asp:ScriptReference Path="~/Admin/js/PostBackPrecedence.js" />
                    </Scripts>
                </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <div class="boxContent">
                            <div class="boxTitle">
                                <h2><asp:Label ID="lblTitle" runat="server" Text="日志"></asp:Label></h2>
                                <ul>
                                    <li><a href="javascript:AddRecord();">添加日志</a></li>
                                </ul>
                            </div>
                            <div class="boxGrid">
                                <uc2:Pager ID="Pager1" runat="server" OnPagerIndexChanged="Pager1_PagerIndexChanged" />
                                <table border="0" cellpadding="0" cellspacing="0" id="boxTable">
                                    <thead>
                                        <tr>
                                            <th class="alignLeft th-first">
                                                标题
                                            </th>
                                            <th style="width: 100px;">
                                                类型
                                            </th>
                                            <th style="width: 50px;">
                                                回复
                                            </th>
                                            <th style="width: 60px;">
                                                状态
                                            </th>
                                            <th style="width: 130px;" class="th-last">
                                                操作
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <asp:Repeater ID="DataRepeater" runat="server">
                                            <ItemTemplate>
                                                <tr>
                                                    <td class="alignLeft td-first">
                                                        <a href=""><%# Eval("Title") %></a>(<%# Eval("AddedDate")%>)
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("Name") %>
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("Num") %>
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("StatusName")%>
                                                    </td>
                                                    <td class="alignLeft td-last">
                                                        <a href="javascript:EditRecord(<%# Eval("Id") %>)" <%# Eval("edit") %>>编辑</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Published %> )" <%# Eval("publish") %> onclick="return ConfirmCmd(1)">发布</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Ready %> )" <%# Eval("unpublish") %> onclick="return ConfirmCmd(2)">取消发布</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Deleted %> )" <%# Eval("delete") %> onclick="return ConfirmCmd(3)">删除</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Ready %> )" <%# Eval("undelete") %> onclick="return ConfirmCmd(4)">取消删除</a>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                            <AlternatingItemTemplate>
                                                <tr style="background-color: rgb(245,245,245)">
                                                    <td class="alignLeft td-first">
                                                        <a href=""><%# Eval("Title") %></a>(<%# Eval("AddedDate")%>)
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("Name") %>
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("Num") %>
                                                    </td>
                                                    <td class="alignCenter">
                                                        <%# Eval("StatusName")%>
                                                    </td>
                                                    <td class="alignLeft td-last">
                                                        <a href="javascript:EditRecord(<%# Eval("Id") %>)" <%# Eval("Edit") %>>编辑</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Published %>)" <%# Eval("publish") %> onclick="return ConfirmCmd(1)">发布</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Ready %> )" <%# Eval("unpublish") %> onclick="return ConfirmCmd(2)">取消发布</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Deleted %> )" <%# Eval("delete") %> onclick="return ConfirmCmd(3)">删除</a>
                                                        <a href="javascript:UpdateRecordType(<%# Eval("Id") %>, <%=RecordStatus.Ready %> )" <%# Eval("undelete") %> onclick="return ConfirmCmd(4)">取消删除</a>
                                                    </td>
                                                </tr>
                                            </AlternatingItemTemplate>
                                        </asp:Repeater>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <asp:Button ID="btnRefresh" runat="server" Text="refresh" CssClass="hiddenButton" onclick="btnRefresh_Click" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>
</asp:Content>
